package de.jonasjelten.jcalc.mathExps;

import de.jonasjelten.jcalc.exception.JEvaluationException;
import de.jonasjelten.jcalc.math.JNumber;

/**
 *
 * @author michael
 */
public class JNeg extends JSingleArgMathExp {

    public JNeg(JMathExp arg) {
        super(arg);
    }

    @Override
    public JNumber eval() throws JEvaluationException {
        JNumber res = super.eval();
        super.jcalc.expgroup.addActive();
        res = res.negate();
        super.jcalc.expgroup.setInactive();
        return res;
    }

    @Override
    public String toString() {
        return super.toString(true, true, "-");
    }

    @Override
    public boolean isTrivial() {
        return true;
    }
}
